import { createRouter, createWebHashHistory } from 'vue-router'

const router = createRouter({
	history: createWebHashHistory(),
	routes: [
		{
			path: '/',
			redirect: '/me'
		},
		{
			path: '/me',
			name: 'me',
			component: () => import('../views/Me/index.vue'),
			meta: { noTopBar: true }
		},
		{
			path: '/me/info',
			name: 'meInfo',
			component: () => import('../views/Me/info/info.vue'),
			meta: { noTopBar: false }
		},
		{
			path: '/me/message/',
			name: 'meMessage',
			component: () => import('../views/Me/message/index.vue'),
			meta: { noTopBar: false },
			children: [
				{
					path: '',
					name: 'messageRecord',
					component: () => import('../views/Me/message/record.vue'),
					meta: { title: 'Message' }
				},
				{
					path: 'detail',
					name: 'messageDetail',
					component: () => import('../views/Me/message/detail.vue'),
					props: true,
					meta: { title: 'Notice' }
				}
			]
		},
		{
            path: '/me/settings',
            name: 'meSettings',
            component: () => import('../views/Me/settings/settings.vue'),
            meta:{noTopBar:false}
        },
		{
			path: '/me/settings/about',
            name: 'about',
            component: () => import('../views/Me/settings/about.vue'),
            meta:{noTopBar:true}
		},
		{
			path: '/me/feedback',
			name: 'meFeedback',
			component: () => import('../views/Me/feedback/feedback.vue'),
			meta: { noTopBar: false }
		},
		{
            path: '/me/feedback/record',
            name: 'feedbackRecordIndex',
            component: () => import('../views/Me/feedback/index.vue'),
            meta:{noTopBar:false},
            children:[
                {
                    path:'',
                    name:'feedbackRecord',
                    component: () => import('../views/Me/feedback/record.vue'),
                },
                {
                    path:'detail',
                    name:'feedbackDetail',
                    component: () => import('../views/Me/feedback/detail.vue'),
                    props:true,
                }
            ]
        },
		{
			path: '/record',
			name: 'record',
			component: () => import('../views/Record/index.vue'),
			props: true,
			meta: { noTopBar: false }
		},
        {
            path:'/withdraw',
            name:'withdraw',
            component:() => import('../views/Withdraw/index.vue'),
            meta:{noTopBar:false}
        },
        {
            path:'/withdraw/detail',
            name:'withdrawDetail',
            props:true,
            component:() => import('../views/Withdraw/withdraw.vue'),
            meta:{noTopBar:false}
        },
        {
            path:'/withdraw/recharge',
            name:'recharge',
            props:true,
            component:() => import('../views/Withdraw/recharge.vue'),
            meta:{noTopBar:false}
        },
        {
            path:'/withdraw/giftcard',
            name:'giftCard',
            props:true,
            component:() => import('../views/Withdraw/giftCard.vue'),
            meta:{noTopBar:false}
        },
        {
            path:'/withdraw/record',
            name:'withdrawRecord',
            component:() => import('../views/Withdraw/recordV1.15.0.vue'),
            meta:{noTopBar:false}
        },
		{
			path: '/invite',
			name: 'invite',
			component: () => import('../views/Invite/index.vue'),
			meta: { noTopBar: false }
		},
		{
			path: '/member',
			name: 'member',
			component: () => import('../views/Member/index.vue'),
			meta: { noTopBar: false }
		}
	]
})
router.beforeEach((to, from, next) => {
	if (to.meta.noTopBar) {
		setTimeout(() => {
			document.getElementById('app').style.paddingTop = '0'
		}, 150)
	} else {
		setTimeout(() => {
			document.getElementById('app').style.paddingTop = '.48rem'
		}, 150)
	}
	next()
})
export const registerRouter = (app)=>{
    app.use(router)
	return router
}
export default router